<template>
  <view class="work-container">
    <!-- 轮播图 -->
    <uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
      <swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
        <swiper-item v-for="(item, index) in data" :key="index">
          <view class="swiper-item" @click="clickBannerItem(item)">
            <image :src="item.image" mode="aspectFill" :draggable="false" />
          </view>
        </swiper-item>
      </swiper>
    </uni-swiper-dot>

    <!-- 宫格组件 -->
    <uni-section title="工作平台管理" type="line"></uni-section>
    <view class="grid-body">
      <uni-grid :column="3" :showBorder="false">
        <uni-grid-item>
          <view class="grid-item-box" @click="handleToOutbound">
            <uni-icons type="person-filled" size="30"></uni-icons>
            <text class="text">出库扫描</text>
          </view>
        </uni-grid-item>
        <uni-grid-item>
          <view class="grid-item-box" @click="handleToWeight">
            <uni-icons type="staff-filled" size="30"></uni-icons>
            <text class="text">称重管理</text>
          </view>
        </uni-grid-item>
        <uni-grid-item>
          <view class="grid-item-box" @click="handleToRigidTest">
            <uni-icons type="color" size="30"></uni-icons>
            <text class="text">刚性测试</text>
          </view>
        </uni-grid-item>
        <uni-grid-item v-if="showGridItem">
          <view class="grid-item-box" @click="handleToQualityManage">
            <uni-icons type="settings-filled" size="30"></uni-icons>
            <text class="text">品质管理</text>
          </view>
        </uni-grid-item>
		<uni-grid-item>
		  <view class="grid-item-box" @click="handleToFinishProQuery">
		    <uni-icons type="tune" size="30"></uni-icons>
		    <text class="text">成品查询</text>
		  </view>
		</uni-grid-item>
		<uni-grid-item>
		  <view class="grid-item-box" @click="handleToProductWeight">
		    <uni-icons type="bars" size="30"></uni-icons>
		    <text class="text">成品称重</text>
		  </view>
		</uni-grid-item>
        <uni-grid-item>
          <view class="grid-item-box" @click="handleToBoxScanning">
            <uni-icons type="link" size="30"></uni-icons>
            <text class="text">成品关联</text>
          </view>
        </uni-grid-item>
		<uni-grid-item>
		  <view class="grid-item-box" @click="handleToProductCollect">
		    <uni-icons type="cart-filled" size="30"></uni-icons>
		    <text class="text">生产领料</text>
		  </view>
		</uni-grid-item>
		<uni-grid-item v-if="showGridItem">
		  <view class="grid-item-box" @click="handleToProductScrap">
		    <uni-icons type="trash" size="30"></uni-icons>
		    <text class="text">报废业务</text>
		  </view>
		</uni-grid-item>
		<uni-grid-item>
		  <view class="grid-item-box" @click="handleToProductMess">
		    <uni-icons type="wallet" size="30"></uni-icons>
		    <text class="text">量产领料</text>
		  </view>
		</uni-grid-item>
        
      </uni-grid>
    </view>
  </view>
</template>

<script>
	
	import storage from '@/utils/storage'
	
	
  export default {
    data() {
      return {
        current: 0,
        swiperDotIndex: 0,
		 name: this.$store.state.user.name,
		 showGridItem: false  ,// 默认为false，不显示；可以动态修改为true来显示
        data: [{
            image: '/static/images/banner/banner01.jpg'
          },
          {
            image: '/static/images/banner/banner02.jpg'
          },
          {
            image: '/static/images/banner/banner03.jpg'
          }
        ]
      }
    },
    methods: {
      clickBannerItem(item) {
        console.info(item)
      },
      changeSwiper(e) {
        this.current = e.detail.current
      },
	  onLoad() {
		const user =  this.$store.state.user.name
		if(user == "三楼品检"){
			console.log("显示:"+ this.$store.state.user.name)
			this.showGridItem = true
			
			
		}else{
			console.log("隐藏:"+ this.$store.state.user.name)
			
			
		}
	  		
	  },
      // changeGrid(e) {
		  // this.$tab.navigateTo('/pages/mine/avatar/index')
		  
        //this.$modal.showToast('模块建设中~')
      // },
	  handleToOutbound() {
	    this.$tab.navigateTo('/pages/longyi/bindBoxCode/index')
	  },
	  handleToWeight() {
	    this.$tab.navigateTo('/pages/longyi/weight/index')
	  },
	  handleToRigidTest() {
	    this.$tab.navigateTo('/pages/longyi/rigidTest/index')
	  },
	  handleToBalance() {
	    this.$tab.navigateTo('/pages/longyi/balanceTest/index')
	  },
	  handleToQualityManage() {
	    this.$tab.navigateTo('/pages/longyi/qualityManage/index')
	  },
	  handleToFinishProQuery() {
	    this.$tab.navigateTo('/pages/longyi/finishProQuery/index')
	  },
	  handleToBoxScanning() {
	    this.$tab.navigateTo('/pages/longyi/boxScanning/index')
	  },
	  handleToProductWeight() {
	    this.$tab.navigateTo('/pages/longyi/productWeight/index')
	  },
	  handleToProductCollect(){
		  this.$tab.navigateTo('/pages/longyi/productCollect/index')
	  },
	  handleToProductScrap(){
		  this.$tab.navigateTo('/pages/longyi/productScrap/index')
	  },
	  handleToProductMess(){
		  this.$tab.navigateTo('/pages/longyi/productMess/index')
	  }
    }
  }
</script>

<style lang="scss">
  /* #ifndef APP-NVUE */
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #fff;
    min-height: 100%;
    height: auto;
  }

  view {
    font-size: 14px;
    line-height: inherit;
  }

  /* #endif */

  .text {
    text-align: center;
    font-size: 26rpx;
    margin-top: 10rpx;
  }

  .grid-item-box {
    flex: 1;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 0;
  }

  .uni-margin-wrap {
    width: 690rpx;
    width: 100%;
    ;
  }

  .swiper {
    height: 300rpx;
  }

  .swiper-box {
    height: 150px;
  }

  .swiper-item {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    height: 300rpx;
    line-height: 300rpx;
  }

  @media screen and (min-width: 500px) {
    .uni-swiper-dot-box {
      width: 400px;
      /* #ifndef APP-NVUE */
      margin: 0 auto;
      /* #endif */
      margin-top: 8px;
    }

    .image {
      width: 100%;
    }
	
	.hide {
	  display: none; /* 完全隐藏 */
	}
  }
</style>
